import copy

class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        ret = []
        acc = []
        def find(nums):
            if len(nums)==0:
                ret.append(copy.copy(acc))
                return
            tmp = copy.copy(nums)
            for num in nums:
                acc.append(num)
                tmp.remove(num)
                find(tmp)
                tmp.add(num)
                acc.pop()
        
        find(set(nums))
        return ret

print(Solution().permute([1,2,3]))